package lw.map_study;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapTest {
    //Map集合的测试类并迭代
    public static void main(String[] args) {
        //创建Map对象
        Map map = new HashMap();       ////
        //添加元素
        map.put("1", "张三");
        map.put("2", "李四");
        map.put("3", "王五");////////
        map.put("3", "王五2");
        map.remove("3");
        map.put("4", "赵六");
        //迭代
        Set keySet = map.keySet();   ////
        Iterator it = keySet.iterator();//////////
        while(it.hasNext()){
            Object key = it.next();//////////
            Object value = map.get(key);///////////
            System.out.println(key+":"+value);
        }
        System.out.println("===============");
        System.out.println(map.size());
        System.out.println(map.containsKey("1"));
        System.out.println(map.containsValue("张三"));
        System.out.println(map.isEmpty());
    }
}
